php forum
php mysql forum
php mysql smarty
 
Topic Options
#317116 - 05/31/08 07:06 AM [7.3] Average Daily Post count
Carte Blanche Offline
Newbie

Registered: 10/08/06
Posts: 21
Loc: Auckland, NZ
From the posts in the last 24 hours topic, here , someone asked about having an average daily post count...so I quickly whipped this up. It needs a small bit of polish to remove the decimals...but, here we go.

In /cache_builders/forum_stats.php
Find:
Code:
$smarty->assign("maxonline",$maxonline);


add before:

Code:
$days = 30;

$today = $html -> get_date();
$limittime = ($today - ($days * 86400));


$query = "
	SELECT count(POST_ID)
	FROM {$config['TABLE_PREFIX']}POSTS
	WHERE POST_POSTED_TIME > $limittime
";

$sth = $dbh->do_query($query);
list($total_posts) = $dbh->fetch_array( $sth );
$avg_posts = ($total_posts / $days);

$smarty->assign("avgposts", $avg_posts);


You may set the time period to be whatever number of days you're wishing to average over. Also, if someone could give me the better division method to remove decimals, that'd be great. Anyway, on to the rest...

In /languages/english/portal_islands.php
Find:
Code:
$ubbt_lang['TOP_POSTERS'] = "Top Posters";


Add after:
Code:
$ubbt_lang['AVG_POSTS'] = " is the daily post average";



Or however you'd like to phrase that.

In /templates/default/island_forum_stats.tpl
Find:
Code:
<b>{$posts}</b> <?php echo $ubbt_lang['POSTS'] ?>


Add after:
Code:
<b>{$avgposts}</b> <?php echo $ubbt_lang['AVG_POSTS'] ?>


Hmm...I may have a quick update to this after I check out some thoughts on how best to use mod...I'm thinking maybe I should check to see if the mod is greater than 0, and if it is, then subtract the mod value from the total posts value, THEN divide it by the days so that I always end up with integer value....will post the revised code if that works.

Yes, that works, so use the code I have above for forum_stats if you want decimal values. If you don't want decimal values, and just want whole integer values....

In /cache_builders/forum_stats.php
Find:
Code:
$smarty->assign("maxonline",$maxonline);


add before:

Code:
$days = 30;

$today = $html -> get_date();
$limittime = ($today - ($days * 86400));


$query = "
	SELECT count(POST_ID)
	FROM {$config['TABLE_PREFIX']}POSTS
	WHERE POST_POSTED_TIME > $limittime
";

$sth = $dbh->do_query($query);
list($total_posts) = $dbh->fetch_array( $sth );
$avg_posts_mod = ($total_posts % $days);
$total_posts = ($total_posts - $avg_posts_mod);
$avg_posts = ($total_posts / $days);

$smarty->assign("avgposts", $avg_posts);



Edited by Carte Blanche (05/31/08 07:21 AM)
Edit Reason: epiphany

Top
#317119 - 05/31/08 11:35 AM Re: [7.3] Average Daily Post count [Re: Carte Blanche]
AllenAyres Offline

I type Like navaho

Registered: 03/10/00
Posts: 25580
Loc: Texas
Very nice Carte Blanche - thank you for sharing thumbsup
_________________________
- Allen wavey
- What Drives You?

Top
#317139 - 06/01/08 11:09 PM Re: [7.3] Average Daily Post count [Re: AllenAyres]
willing Offline
User

Registered: 04/17/07
Posts: 42
Thank you so much!

smile

Top



Moderator:  sirdude 
Latest Posts
[7.2.1] - Naked shoutbox
by bellaonline
05/05/12 05:00 PM
[7.x] Stop Forum Spam Integration v0.4
by bellaonline
05/05/12 03:53 PM
Shout Box

(Views)Popular Topics
Known public proxy servers 1689885
Integrated Index Page (IIP) 5.3.1 555705
Finished-[6.5.2] Games Arcade Deluxe v1.9 501236
Integrated Index Page (IIP) 5.1.1 415112
TLD Bv2.1 Released - Threads Links Directory 396822
[6.0x] Who's Online 4.0.0 [Finished] 389412
Finished-[6.5.1] Integrated Index Page (IIP) 6.5 330423
Q & A 298663
Slash UBB 266936
[6.3.x] [beta] Hit Hack 2.0 227970
Forum Stats
13621 Members
59 Forums
37191 Topics
295716 Posts

Max Online: 686 @ 06/28/07 07:04 AM

 

 

 
fusionbb message board php hacks